﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Dtos
{
    public class TokenDto
    {
        //jwtid
        public string id { get; set; }
        //自定义：许可证key
        public string pkey { get; set; }
        //颁发者
        public string iss { get; set; }
        //用户
        public string aud { get; set; }

        //生效时间
        public long nbf { get; set; }
        //到期时间
        public long exp { get; set; }
        //发布时间
        public long iat { get; set; }

        public static DateTime GetDateTime(long timeStamp)
        {
            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            long lTime = ((long)timeStamp * 10000000);
            TimeSpan toNow = new TimeSpan(lTime);
            DateTime targetDt = dtStart.Add(toNow);

            if (string.IsNullOrEmpty(targetDt.ToString()))
            {
                targetDt = DateTime.Now;
            }

            return targetDt;
        }

        //public static string GetDateTimeString(int timeStamp)
        //{

        //}
    }
}
